﻿<%@ page language="java" import="java.util.*,code.bean.*"
	pageEncoding="UTF-8"%>
<%@ page import="code.util.ParamUtils"%>
<%@ page import="code.util.DateUtils"%>
<%@ page import="java.util.Calendar"%>
<%@ page import="code.util.PageObject" %>
<%@ page import="code.op.*"%>

	<SCRIPT language="javascript" src="js/http.js"></SCRIPT>
	<SCRIPT language="javascript" src="js/code.js"></SCRIPT>
	<%String path = request.getContextPath();
			String basePath = request.getScheme() + "://"
					+ request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>
<%
	PageObject pageObject = (PageObject)ParamUtils.getObjectAttribute(request, "items", null);
	List items = pageObject.getList();
	Item item = new Item();
	int i;
	User loginUser = (User)ParamUtils.getObjectAttribute(session, "loginUser", null);

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>历史版本</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		
		<link href="css/s.css" rel="stylesheet" type="text/css" />
        <link href="css/comment_7.css" rel="stylesheet" type="text/css" />
		<link type="text/css" rel="stylesheet" href="Styles/SyntaxHighlighter.css">
</link>
</head>
<body>

<div id="head">
	<div class="hd">
		<div class="l tac wl2" style="width:720px;padding:3px;">
		<table width="100%"><tr>
			<td><div style="padding-left:15px;"><a href="servlet/ShowIndex1"><img src="images/pcslogo.gif"/></a></div></td>
			<td class="ce" style="font-size:14px">
			&nbsp;<a href="servlet/ShowSpace?userid=<%=ParamUtils.getParameter(request, "userid", "")%>" class="ce">主页</a>&nbsp;┊
			&nbsp;<a href="servlet/ShowCode?userid=<%=ParamUtils.getParameter(request, "userid", "")%>&blogdate=<%=DateUtils.format(Calendar.getInstance().getTime())%>" class="ce">我的代码</a>&nbsp;┊
			&nbsp;<a href="servlet/ShowShare?userid=<%=ParamUtils.getParameter(request, "userid", "")%>" class="ce">我的收藏</a>&nbsp;┊
			&nbsp;<a href="servlet/ShowProfile?userid=<%=ParamUtils.getParameter(request, "userid", "")%>" class="ce">用户信息</a>&nbsp;┊
			&nbsp;<a href="servlet/ManageCode?userid=<%=ParamUtils.getParameter(request, "userid", "")%>&cmd=add" class="ce">发布代码</a>&nbsp;┊
			&nbsp;<a href="../CodeSharer/advSearch.jsp?userid=<%=ParamUtils.getParameter(request, "userid", "")%>" class="ce">搜索</a>
			
			<%
				if(session.getAttribute("loginUser") != null && ((User)(session.getAttribute("loginUser"))).getId().equals(ParamUtils.getParameter(request, "userid", "")))
			    { 
					out.println("&nbsp;┊&nbsp;<a href=\"servlet/CodeList?userid=" + ParamUtils.getParameter(request, "userid", "") + "\" class=\"ce"+"\">代码管理</a>");
				    out.println("&nbsp;┊&nbsp;<a href=\"servlet/ShareList?userid=" + ParamUtils.getParameter(request, "userid", "") + "\" class=\"ce"+"\">收藏管理</a>");
				    out.println("&nbsp;┊&nbsp;<a href=\"servlet/DoLogout" + "\" class=\"ce"+"\">退出</a>");
				}
			%>
			</td>
		</tr></table>
		</div>
		<div align="right">
			<table>
			<tr>
			<td>
			    <div style="padding:4px;"></div>
				<form name="" action="servlet/SearchCodeByTitle?userid=<%=ParamUtils.getParameter(request, "userid", "")%>" method="post">
				<input type="text" name = "title1" value="" maxlength="15"/>
				<input type="submit" class="signinbtn1" value="搜标题"/>
				</form>
			</td>
			<td>
			&nbsp;&nbsp;&nbsp;&nbsp;
			<%if(session.getAttribute("loginUser") != null){ %>
			<a href="servlet/ShowSpace?userid=<%=
			((User)
			(session.getAttribute
			("loginUser"))).getId()
			%>" class="ce" style="font-size:16px">
			<%=((User)
			(session.getAttribute
			("loginUser"))).getNickName()%>
			</a>
			<%}%>
			</td>
			</tr>
			</table>
		</div>
		<div class="c"></div>
	</div>
</div>

	<table width="75%" align="center">
		
		
		<tr>
			<td style="font-size: 16px">
			 <div style="padding:15px;"></div>
				<%
					if(items.size() > 0 ){
						out.println("历史各版本");
				
						for( i = 0; i < items.size(); i++){
							item = (Item)items.get(i);
							String content = "content" + i;
				%>
			<div style="padding:6px;"></div>
					<table width="80%">
						<tr>
							<td colspan="2" align="left" style="font-size: 12px;">
								<%=item.getUpdatetime().substring(5,7)%>月<%=item.getUpdatetime().substring(8,10)%>日
								<%=item.getUpdatetime().substring(11,13) %>时<%=item.getUpdatetime().substring(14,16)%>分<%=item.getUpdatetime().substring(17,19)%>秒
								
							</td>
							<%						
							if(session.getAttribute("loginUser") != null &&
							(((User)(session.getAttribute("loginUser"))).getId().equals(ParamUtils.getParameter(request, "userid", ""))))
							{
							%>
							<td>
							<input type="button" class="signinbtn1" onclick="location.href='../servlet/ManageCode?itemid=<%=item.getId()%>&cmd=<%="delItem"%>&userid=<%=loginUser.getId()%>&codeid=<%=item.getCodeid()%>'" value="删除">
							</td>
							<%
							} 
							%>
						</tr>
						<tr>
							<td><hr width="100%" align="right"/></td>
						</tr>
						<tr>
							<td colspan="2">
							</td>
						</tr>
						<tr>
							<td height="10" colspan="2">更新说明:&nbsp;&nbsp;&nbsp;<%=item.getCaption()%></td>
						</tr>
						<tr>
							<td colspan="2">
								<textarea name=<%=content%> class= <%=item.getLanguage()%> cols="50" rows="20" readonly><%=item.getContent()%>    
								</textarea>
								<script class="javascript" src="Scripts/shCore.js"></script>
								<script class="javascript" src="Scripts/shBrushCSharp.js"></script>
								<script class="javascript" src="Scripts/shBrushPhp.js"></script>
								<script class="javascript" src="Scripts/shBrushJScript.js"></script>
								<script class="javascript" src="Scripts/shBrushJava.js"></script>
								<script class="javascript" src="Scripts/shBrushVb.js"></script>
								<script class="javascript" src="Scripts/shBrushSql.js"></script>
								<script class="javascript" src="Scripts/shBrushXml.js"></script>
								<script class="javascript" src="Scripts/shBrushDelphi.js"></script>
								<script class="javascript" src="Scripts/shBrushPython.js"></script>
								<script class="javascript" src="Scripts/shBrushRuby.js"></script>
								<script class="javascript" src="Scripts/shBrushCss.js"></script>
								<script class="javascript" src="Scripts/shBrushCpp.js"></script>&nbsp;
								<script class="javascript">
								dp.SyntaxHighlighter.HighlightAll('<%=content%>');
								</script>
							</td>
						</tr>
					</table>
					<hr width="100%" align="left" style="border-top: 2px dashed; border-bottom: 2px dashed; height: 1px ; border-color:gray">
					<br/>
					<br/>
				<%
						}
					}
					else{
						out.print("此存档中没有项<br><br>");
						}
				%>
			</td>
		</tr>
		<tr align="center"><td>
		<input width="49" type="button" height="18" class="signinbtn1" value="返回" onclick="history.back(-1)">
		</td></tr>
	</table>
	</body>
	</html>
	